package emulator.unittest.hardware.bits;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import emulator.hardware.bits.SerialBit;
import emulator.hardware.bits.SharedBit;

public class SerialBitTest 
{
	private SharedBit inBit;
	private SerialBit serialBit;

	@Before
	public void setUp() throws Exception
	{
		inBit = new SharedBit();
		serialBit = new SerialBit(inBit);
	}

	@Test
	public void testFalseBusTrue() 
	{
		serialBit.setBusBit(true);
		serialBit.setValue(false);
		assertEquals(false, serialBit.getValue());
		assertEquals(true, inBit.getValue());
	}

	@Test
	public void testTrueBusTrue() 
	{
		serialBit.setBusBit(true);
		serialBit.setValue(true);
		assertEquals(true, serialBit.getValue());
		assertEquals(false, inBit.getValue());
	}

	@Test
	public void testFalseBusFalse() 
	{
		serialBit.setBusBit(false);
		serialBit.setValue(false);
		assertEquals(false, serialBit.getValue());
		assertEquals(false, inBit.getValue());
	}

	@Test
	public void testTrueBusFalse() 
	{
		serialBit.setBusBit(false);
		serialBit.setValue(true);
		assertEquals(true, serialBit.getValue());
		assertEquals(false, inBit.getValue());
	}
}
